package com.example.simpleforum.model;

import java.sql.Timestamp;

/**
 * 板块申请实体类
 */
public class ForumApplication {
    public enum Status {
        pending("待审核"),
        approved("已通过"),
        rejected("已拒绝");
        
        private final String displayName;
        
        Status(String displayName) {
            this.displayName = displayName;
        }
        
        public String getDisplayName() {
            return displayName;
        }
    }
    
    private int id;                 // 申请ID
    private Integer forumId;        // 申请管理的板块ID，为NULL时表示申请创建新板块
    private String forumName;       // 申请创建的板块名称，申请管理已有板块时为NULL
    private String forumDescription; // 申请创建的板块描述，申请管理已有板块时为NULL
    private int applicantId;        // 申请人ID
    private String reason;          // 申请理由
    private Status status;          // 申请状态
    private Integer reviewerId;     // 审核人ID（主管理员）
    private Timestamp reviewTime;   // 审核时间
    private String reviewNotes;     // 审核备注
    private Timestamp applyTime;   // 申请时间

    // 构造函数
    public ForumApplication() {
    }

    public ForumApplication(Integer forumId, int applicantId, String reason) {
        this.forumId = forumId;
        this.applicantId = applicantId;
        this.reason = reason;
        this.status = Status.pending;
    }
    
    public ForumApplication(String forumName, String forumDescription, int applicantId, String reason) {
        this.forumName = forumName;
        this.forumDescription = forumDescription;
        this.applicantId = applicantId;
        this.reason = reason;
        this.status = Status.pending;
    }

    // Getter和Setter方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Integer getForumId() {
        return forumId;
    }

    public void setForumId(Integer forumId) {
        this.forumId = forumId;
    }
    
    public String getForumName() {
        return forumName;
    }

    public void setForumName(String forumName) {
        this.forumName = forumName;
    }

    public String getForumDescription() {
        return forumDescription;
    }

    public void setForumDescription(String forumDescription) {
        this.forumDescription = forumDescription;
    }

    public int getApplicantId() {
        return applicantId;
    }

    public void setApplicantId(int applicantId) {
        this.applicantId = applicantId;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Integer getReviewerId() {
        return reviewerId;
    }

    public void setReviewerId(Integer reviewerId) {
        this.reviewerId = reviewerId;
    }

    public Timestamp getReviewTime() {
        return reviewTime;
    }

    public void setReviewTime(Timestamp reviewTime) {
        this.reviewTime = reviewTime;
    }

    public String getReviewNotes() {
        return reviewNotes;
    }

    public void setReviewNotes(String reviewNotes) {
        this.reviewNotes = reviewNotes;
    }

    public Timestamp getApplyTime() {
        return applyTime;
    }

    public void setApplyTime(Timestamp applyTime) {
        this.applyTime = applyTime;
    }

    public String getStatusDisplayName() {
        return status != null ? status.getDisplayName() : "";
    }

    @Override
    public String toString() {
        return "ForumApplication{" +
                "id=" + id +
                ", forumId=" + forumId +
                ", forumName='" + forumName + '\'' +
                ", applicantId=" + applicantId +
                ", status=" + status +
                ", applyTime=" + applyTime +
                '}';
    }
}